<template>
  <div class="flex flex-col h-full">
    <SearchContainer @reset="() => formRef.resetFields()" @search="getData()">
      <a-form ref="formRef" class="flex-1" :model="formState" :label-col="{ style: { width: '70px' } }">
        <a-form-item name="pyjm" class="w-1/5">
          <a-input v-model:value="formState.pyjm" placeholder="诊断名称/诊断代码/助记码" />
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2 flex-1">
      <div class="flex mb-3">
        <a-button type="primary" class="mr-2" @click="onClickAdd">新增</a-button>
        <BaseExport type="医保" name="国家医保诊断代码" code="001057" :search-params="formState">导出</BaseExport>
      </div>
      <BaseTable fill column-code="001057" :data-source="tableData" bordered :loading="loading" :pagination="pagination">
        <template #bodyCell="{ column, index, record }">
          <template v-if="column.dataIndex === 'xh'">
            {{ index + 1 }}
          </template>
          <template v-if="column.dataIndex === 'action'">
            <a-button type="link" size="small" @click="onClickAdd(record)">修改</a-button>
          </template>
        </template>
      </BaseTable>
    </a-card>
    <Edit v-model:open="editOpen" :row-data="rowData" @ok="getData" />
  </div>
</template>

<script setup>
import { ref } from 'vue'
import SearchContainer from '@/components/SearchContainer'
import BaseTable from '@/components/BaseTable'
// import UploadTxt from '../components/UploadTxt'
import Edit from './Edit.vue'

const formRef = ref(null)
const editOpen = ref(false)
const rowData = ref({})
const formState = ref({ pyjm: '' })

const { loading, tableData, getData, pagination } = useTable({
  url: '/common/masterData/getNmiDictIcd10List',
  params: formState.value,
  immediate: true
})

const onClickAdd = (row) => {
  rowData.value = { ...row }
  editOpen.value = true
}
</script>
<style lang="less" scoped></style>
